<template>
  <el-dialog
    :visible.sync="dialogVisible"
    :before-close="handleClose"
    :close-on-click-modal="false"
    title="解锁"
    width="400px">
    <el-form :model="formInline">
      <el-form-item :label="$t('remark')" label-width="60px">
        <el-input
          v-model="formInline.remark"
          style="width: '100%'"
          type="textarea"
          rows="3"
          placeholder="请输入内容"
          maxlength="200"
          show-word-limit
        />
      </el-form-item>
    </el-form>
    <span slot="footer">
      <el-button icon="el-icon-circle-close" @click="handleClose">{{
        $t("cancel")
      }}</el-button>
      <el-button type="primary" icon="el-icon-unlock" @click="doUnLock" >
        {{ $t('unlock') }}
      </el-button>
    </span>
  </el-dialog>
</template>

<script>
import { handleUnLock } from '@/api/alarm/unlock'
export default {
  name: 'UnlockRemark',
  data() {
    return {
      dialogVisible: false,
      formInline: {}
    }
  },
  methods: {
    handleOpen(row) {
      this.formInline = Object.assign({}, row)
      this.dialogVisible = true
    },
    doUnLock() {
      handleUnLock({
        id: this.formInline.id,
        remark: this.formInline.remark
      }).then(res => {
        this.$betterTips(res, this.handleUpdate, this.handleClose)
      })
    },
    handleUpdate() {
      this.$emit('initList')
    },
    handleClose() {
      Object.assign(this.$data, this.$options.data.call(this))
    }
  }
}
</script>

